CMAKE_MINIMUM_REQUIRED(VERSION 3.17)

SET(CMAKE_C_EXTENSIONS OFF)
SET(CMAKE_CXX_EXTENSIONS OFF)

ADD_LIBRARY(librariesOpenSSL INTERFACE)
ADD_LIBRARY(LIBRARIES::OPENSSL ALIAS librariesOpenSSL)

IF (CMAKE_SYSTEM MATCHES "Windows")
    TARGET_INCLUDE_DIRECTORIES(librariesOpenSSL INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/windows/include")
    FIND_LIBRARY(OPENSSL_LIBCRYPTO NAMES libcrypto PATHS ${CMAKE_CURRENT_SOURCE_DIR}/windows/lib NO_DEFAULT_PATH)
    FIND_LIBRARY(OPENSSL_LIBSSL NAMES libssl PATHS ${CMAKE_CURRENT_SOURCE_DIR}/windows/lib NO_DEFAULT_PATH)
    TARGET_LINK_LIBRARIES(librariesOpenSSL INTERFACE
            ${OPENSSL_LIBCRYPTO}
            ${OPENSSL_LIBSSL})
ELSEIF (CMAKE_SYSTEM MATCHES "Linux")
    TARGET_INCLUDE_DIRECTORIES(librariesOpenSSL INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/ubuntu/include")
    FIND_LIBRARY(OPENSSL_LIBCRYPTO NAMES crypto PATHS ${CMAKE_CURRENT_SOURCE_DIR}/ubuntu/lib NO_DEFAULT_PATH)
    FIND_LIBRARY(OPENSSL_LIBSSL NAMES ssl PATHS ${CMAKE_CURRENT_SOURCE_DIR}/ubuntu/lib NO_DEFAULT_PATH)
    TARGET_LINK_LIBRARIES(librariesOpenSSL INTERFACE
            ${OPENSSL_LIBCRYPTO}
            ${OPENSSL_LIBSSL})
ELSEIF (CMAKE_SYSTEM MATCHES "Android")
    TARGET_INCLUDE_DIRECTORIES(librariesOpenSSL INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/android_armv7/include")
    FIND_LIBRARY(OPENSSL_LIBCRYPTO NAMES crypto PATHS ${CMAKE_CURRENT_SOURCE_DIR}/android_armv7/lib NO_DEFAULT_PATH)
    FIND_LIBRARY(OPENSSL_LIBSSL NAMES ssl PATHS ${CMAKE_CURRENT_SOURCE_DIR}/android_armv7/lib NO_DEFAULT_PATH)
    TARGET_LINK_LIBRARIES(librariesOpenSSL INTERFACE
            ${OPENSSL_LIBCRYPTO}
            ${OPENSSL_LIBSSL})
ENDIF ()